-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: mode selector settings sync with url correctly #1202
Conversation
@@ -223,6 +225,10 @@ function BatchSettings({ | |||
) | |||
const accentColor = tinycolor(baseColor).darken(10) | |||
|
|||
const _onSettingsUpdate = (params: any) => { | |||
setQueryParam({ queryParamData: params, ...params }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should setQueryParam
be used for callback _toggleModeButton
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use it for that! I don't know of any sync bugs affecting that, I think because those keys are not in conflict with the ones defined in query-params.js in core-utils. But I think it wouldn't hurt to use it and would probably make things more resilient. I'll try it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix. Keep us posted regarding #1202 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working great!
@@ -81,6 +82,7 @@ function BatchSettings({ | |||
modeSettingValues, | |||
onPlanTripClick, | |||
routingQuery, | |||
setQueryParam, | |||
setUrlSearch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need setUrlSearch
? Is it used somewhere else? Should we use something else instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-heppner-ibigroup Yeah you can delete setUrlSearch
from this file.
Description:
The root of this bug is that we replace the URL search with the
currentQuery
every time a trip plan is sent off for keys that are defined incore-utils
query-params
file. However, in some cases (it seems like when a request isn't successful), thecurrentQuery
doesn't get updated with new values from the mode selector. This sync issue means that the old value fromcurrentQuery
replaces the value in the URL.I found what I think is the simplest way of fixing this, by ensuring that the
currentQuery
is directly updated at the same time that URL is updated by the mode selector. However, it looks a bit weird because thesetQueryParam
function only updates URL search values stored insidequeryParamData
, while the higher level gets put in currentQuery directly. A bit funky.PR Checklist: